import Vue from 'vue'
import VueRouter from 'vue-router'
import loginRoute from './modules/login/loginRoute.js'
import adminRoute from './modules/admin/adminRoute.js'
Vue.use(VueRouter)

export const routes = [{
		path: '/',
		redirect: '/login',
	},
	loginRoute
]

export const asyncRoute = [adminRoute]
export const anyRoute = [{
	path: '/pdfPreview',
	name: 'pdfPreview',
	meta: { title: 'PDF预览' },
	component: () => import('@/components/pdf/config.vue'),
}, {
	path: '/collectPreview',
	name: 'collectPreview',
	meta: { title: '采集预览' },
	component: () => import('@/views/module/column/Collect/Public/Preview.vue'),
}, {
	path: '/maintained',
	name: 'maintained',
	meta: { title: '平台维护中' },
	component: () => import('@/views/404/Maintained.vue'),
}, {
	path: '*',
	name: 'wrong-page',
	component: () => import('@/views/404/index.vue'),
}]
export const router = new VueRouter({
	routes,
	linkActiveClass: 'active',
	scrollBehavior(to, from, savedPosition) {
		// 期望滚动到哪个的位置
		return { x: 0, y: 0 }
	},
})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
	return VueRouterPush.call(this, to).catch((err) => err)
}